package org.htzb.news.dao;
import java.sql.*;
import javax.sql.DataSource;
import com.mchange.v2.c3p0.ComboPooledDataSource;


public class C3P0Util {
    private static DataSource dataSource = new ComboPooledDataSource();
    public Connection connection=null;
    protected Statement  statement=null;
    protected PreparedStatement preparedStatement=null;
    protected ResultSet resultSet=null;


    //从连接池中获取连接
    public Connection getConnection() {
        try {
            System.out.println("db===>"+dataSource);
            connection=dataSource.getConnection();
            System.out.println("数据库连接成功"+connection);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            throw new RuntimeException();
        }
        return connection;
    }
    public static void main(String[] args) throws SQLException {
        C3P0Util util=new C3P0Util();
        Connection connection1=util.getConnection();

    }
}